package com.feri.redromance01.service.impl;

import com.feri.redromance01.dao.LogisticsDao;
import com.feri.redromance01.entity.Logistics;
import com.feri.redromance01.service.intf.LogisticsService;
import com.feri.redromance01.util.StringUtil;
import com.feri.redromance01.vo.PageBean;
import com.feri.redromance01.vo.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * //                                              __----~~~~~~~~~~~------___
 * //                                        .  .   ~~//====......          __--~ ~~
 * //                        -.            \_|//     |||\\  ~~~~~~::::... /~
 * //                     ___-==_       _-~o~  \/    |||  \\            _/~~-
 * //             __---~~~.==~||\=_    -_--~/_-~|-   |\\   \\        _/~
 * //         _-~~     .=~    |  \\-_    '-~7  /-   /  ||    \      /
 * //       .~       .~       |   \\ -_    /  /-   /   ||      \   /
 * //      /  ____  /         |     \\ ~-_/  /|- _/   .||       \ /
 * //      |~~    ~~|--~~~~--_ \     ~==-/   | \~--===~~        .\
 * //               '         ~-|      /|    |-~\~~       __--~~
 * //                           |-~~-_/ |    |   ~\_   _-~            /\
 * //                                /  \     \__   \/~                \__
 * //                            _--~ _/ | .-~~____--~-/                  ~~==.
 * //                           ((->/~   '.|||' -_|    ~~-/ ,              . _||
 * //                                      -_     ~\      ~~---l__i__i__i--~~_/
 * //                                      _-~-__   ~)  \--______________--~~
 * //                                   //.-~~~-~_--~- |-------~~~~~~~~
 * //                                           //.-~~~--\
 * <p>
 * zpy
 * 2022/8/30
 */
@Service
public class LogisticsServiceImpl implements LogisticsService {
    @Autowired
    private LogisticsDao dao;
    @Override
    public R save(Logistics logistics) {
        System.out.println(logistics);
        if(dao.save(logistics)>0){
            return R.ok();
        }else {
            return R.fail();
        }
    }

    @Override
    public R update(Logistics logistics) {
        if(dao.update(logistics)>0){
            return R.ok();
        }else {
            return R.fail();
        }
    }

    @Override
    public R delete(int lod_id) {
        if(dao.delete(lod_id)>0){
            return R.ok();
        }else {
            return R.fail();
        }
    }

    @Override
    public PageBean selectPage(String log_name, int page, int limit) {
        if(StringUtil.isNotEmpty(log_name)){
            log_name="%"+log_name+"%";
        }
        int start=(page-1)*limit;

        return PageBean.ok(dao.selectCount(log_name),dao.selectPage(log_name,start,limit));
        }
}
